package cn.markjoy.springbootrabbit.controller;

import cn.markjoy.springbootrabbit.common.response.ResponseBaseDto;
import cn.markjoy.springbootrabbit.entity.permission.User;
import cn.markjoy.springbootrabbit.rabbit.producer.Messager;
import cn.markjoy.springbootrabbit.service.permission.UserInfoService;
import cn.markjoy.springbootrabbit.util.response.ApiResponseUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author zhaojiandong
 * @date 2018/8/31
 * @Description
 */
@Controller
@RestController
@RequestMapping("/user")
public class UserController
{
    @Autowired
    private UserInfoService userInfoService;

    @RequestMapping(value = "/list", method = RequestMethod.POST)
    public ResponseBaseDto listUserInfo(@RequestBody(required = false) User userModel)
    {
        List<User> list = userInfoService.listUserInfo(userModel);
        return ApiResponseUtil.success(list);
    }

    @RequestMapping(value = "/testQueue", method = RequestMethod.POST)
    public ResponseBaseDto testQueue(@RequestBody(required = false) User userModel)
    {
        Messager messager = new Messager();
        messager.send();
        return ApiResponseUtil.success();
    }
}
